package lingqi.library.input;

import java.util.Scanner;

public class Input {
    private final Scanner scanner = new Scanner(System.in);

    public String prompt(String prompt) throws QuitException{   //这个异常由 Main 来负责
        System.out.println(prompt + ":");
        System.out.print("> ");
        if(!scanner.hasNextLine()){
            // scanner.hasNextLine() 为false 代表用户按下 ctrl + D ，说明想退出
            //通过异常方式，向外通知
            throw new QuitException();
        }
        return scanner.nextLine();

    }
}
